import axios from 'axios'
import qs from 'qs'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'

const instance = axios.create({
    timeout:5000
})
nprogress.configure({ease:'linear',speed: 500});
instance.interceptors.request.use(config=>{
    nprogress.start()
    if(config.method == 'post'){
        config.data = qs.stringify(config.data)
    }
  
    return config
   

},
error => {
    return Promise.reject(error)
    } 
)

instance.interceptors.response.use(result=>{

    nprogress.done()
    return result.data //response返回直接返回对象中的Date;
},
onReject =>{

    return Promise.reject(onReject)

})

export default instance;